home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
bbsutil
/
bsrc_250.zip
/
B_FRPROC.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-09-15
|
25KB
|
792 lines
/*--------------------------------------------------------------------------*/
/* */
/* */
/* ------------ Bit-Bucket Software, Co. */
/* \ 10001101 / Writers and Distributors of */
/* \ 011110 / Freely Available<tm> Software. */
/* \ 1011 / */
/* ------ */
/* */
/* (C) Copyright 1987-91, Bit Bucket Software Co., a Delaware Corporation. */
/* */
/* */
/* BinkleyTerm File Request Processor */
/* */
/* */
/* For complete details of the licensing restrictions, please refer */
/* to the License agreement, which is published in its entirety in */
/* the MAKEFILE and BT.C, and also contained in the file LICENSE.250. */
/* */
/* USE OF THIS FILE IS SUBJECT TO THE RESTRICTIONS CONTAINED IN THE */
/* BINKLEYTERM LICENSING AGREEMENT. IF YOU DO NOT FIND THE TEXT OF */
/* THIS AGREEMENT IN ANY OF THE AFOREMENTIONED FILES, OR IF YOU DO */
/* NOT HAVE THESE FILES, YOU SHOULD IMMEDIATELY CONTACT BIT BUCKET */
/* SOFTWARE CO. AT ONE OF THE ADDRESSES LISTED BELOW. IN NO EVENT */
/* SHOULD YOU PROCEED TO USE THIS FILE WITHOUT HAVING ACCEPTED THE */
/* TERMS OF THE BINKLEYTERM LICENSING AGREEMENT, OR SUCH OTHER */
/* AGREEMENT AS YOU ARE ABLE TO REACH WITH BIT BUCKET SOFTWARE, CO. */
/* */
/* */
/* You can contact Bit Bucket Software Co. at any one of the following */
/* addresses: */
/* */
/* Bit Bucket Software Co. FidoNet 1:104/501, 1:343/491 */
/* P.O. Box 460398 AlterNet 7:491/0 */
/* Aurora, CO 80046 BBS-Net 86:2030/1 */
/* Internet f491.n343.z1.fidonet.org */
/* */
/* Please feel free to contact us at any time to share your comments about */
/* our software and/or licensing policies. */
/* */
/* */
/* This module is based largely on a similar module in OPUS-CBCS V1.03b. */
/* The original work is (C) Copyright 1987, Wynn Wagner III. The original */
/* author has graciously allowed us to use his code in this work. */
/* */
/*--------------------------------------------------------------------------*/
/* Include this file before any other includes or defines! */
#include "includes.h"
static char *their_pwd; /* Password in REQ file */
static char required_pwd[10]; /* Password in OK file */
static int xfer_seconds;
int prep_match (char *, char *);
int match (char *, char *);
void run_prog (char *);
int check_password (void);
freq_abort (long, int (*)(long));
int what_event (int);
int what_event_sub (int, int, int, int, int, int);
int prep_match (char *template, char *buffer)
{
register int i, delim;
register char *sptr;
int start;
(void) memset (buffer, 0, 11);
i = (int) strlen (template);
sptr = template;
for (start = i = 0; sptr[i]; i++)
if ((sptr[i] == '\\') || (sptr[i] == ':'))
start = i + 1;
if (start)
sptr += start;
delim = 8; /* last column for ? */
(void) strupr (sptr);
for (i = 0; *sptr && i < 12; sptr++)
switch (*sptr)
{
case '.':
if (i > 8)
return (-1);
while (i < 8)
{
buffer[i++] = ' ';
}
buffer[i++] = *sptr;
delim = 12;
break;
case '*':
while (i < delim)
{
buffer[i++] = '?';
}
break;
default:
buffer[i++] = *sptr;
break;
} /* switch */
while (i < 12)
{
/* dean suggests:
buffer[i++] = (i == delim) ? '.' : ((i > delim) ? '?' : ' ');
to replace the if/else below...
*/
if (i == 8)
buffer[i++] = '.';
else buffer[i++] = ' ';
}
buffer[i] = '\0';
return 0;
}
int match (char *s1, char *s2)
{
register char *i, *j;
i = s1;
j = s2;
while (*i)
{
if ((*j != '?') && (*i != *j))
{
return 1;
}
i++;
j++;
}
return 0;
}
/*--------------------------------------------------------------------------*/
/* Process file requests from the remote system. The filespec requested is */
/* turned into a local filespec if possible, then transferred via the */
/* caller-supplied routine. */
/*--------------------------------------------------------------------------*/
int n_frproc (char *request, int nfiles,
int (*callback)(char *), int (*calltime)(long))
{
register int i;
register int j = 0;
static char s[80];
static char s1[80];
static char s2[80];
char *p;
FILE *approved;
struct FILEINFO dta;
struct stat st;
char *sptr;
char *after_pwd;
long updreq = 0L;
char updtype = 0;
int saved_nfiles;
char our_wildcard[15];
char their_wildcard[15];
int mfunc;
int magic_state = 0;
int tried_about = 0;
int failure_reason = 1; /* 1 = not available */
/* 2 = no update */
/* 3 = bad password */
if (freq_accum.time == 0L)
freq_accum.time = (long)time(NULL);
approved = NULL;
their_pwd = NULL;
after_pwd = NULL;
(void) strcpy (s1, request);
/*--------------------------------------------------------------------*/
/* Fix up the file name */
/*--------------------------------------------------------------------*/
for (i = 0; request[i]; i++)
{
if (request[i] <= ' ')
{
request[i++] = '\0';
j = i;
break;
}
}
if (j)
{
/* If we have a '!', find the end of the password, point j
past it, then truncate and fold if necessary. This leaves
j properly aligned for other fields.
*/
if (request[j] == '!')
{
their_pwd = request + (++j);
for (; request[j]; j++)
{
if (request[j] <= ' ')
{
request[j++] = '\0';
break;
}
}
if (strlen (their_pwd) > 6)
their_pwd[6] = '\0';
(void) fancy_str (their_pwd);
}
/* Test for update/back